import vue from 'vue';

//然后就可以自定义指令

vue.directive('tableDrag', {
  inserted: function () {
    let el = document.getElementsByClassName('ivu-table-body')[0];
    el.style.cursor = 'grab';
    el.onmousedown = function () {
      let gapX = event.clientX;
      let startX = el.scrollLeft;
      document.onmousemove = function (e) {
        let x = e.clientX - gapX;
        el.scrollLeft = startX - x;
        return false;
      };
      document.onmouseup = function (e) {
        document.onmousemove = null;
        document.onmouseup = null;
      };
    };
  }
});